home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / fssock13 / demo / fstest / server.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-23  |  12.5 KB  |  434 lines

  1. VERSION 2.00
  2. Begin Form Server 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Server Test"
  6.    ClientHeight    =   6915
  7.    ClientLeft      =   7860
  8.    ClientTop       =   1605
  9.    ClientWidth     =   6960
  10.    ControlBox      =   0   'False
  11.    Height          =   7320
  12.    Icon            =   SERVER.FRX:0000
  13.    Left            =   7800
  14.    LinkTopic       =   "Form1"
  15.    ScaleHeight     =   6915
  16.    ScaleWidth      =   6960
  17.    Top             =   1260
  18.    Width           =   7080
  19.    Begin TextBox Text2 
  20.       Height          =   285
  21.       Left            =   120
  22.       TabIndex        =   25
  23.       Text            =   "Text2"
  24.       Top             =   6360
  25.       Width           =   855
  26.    End
  27.    Begin TextBox Text1 
  28.       Height          =   285
  29.       Left            =   120
  30.       TabIndex        =   24
  31.       Text            =   "Text1"
  32.       Top             =   6000
  33.       Width           =   855
  34.    End
  35.    Begin TextBox HSTNAME 
  36.       Height          =   285
  37.       Left            =   120
  38.       TabIndex        =   22
  39.       Text            =   "Text1"
  40.       Top             =   2040
  41.       Width           =   2175
  42.    End
  43.    Begin CommandButton Connect 
  44.       Caption         =   "Connect"
  45.       Enabled         =   0   'False
  46.       Height          =   375
  47.       Left            =   1080
  48.       TabIndex        =   21
  49.       Top             =   6000
  50.       Width           =   1215
  51.    End
  52.    Begin TextBox localaddress 
  53.       Height          =   285
  54.       Left            =   120
  55.       TabIndex        =   18
  56.       Top             =   3840
  57.       Width           =   2175
  58.    End
  59.    Begin TextBox localport 
  60.       Height          =   285
  61.       Left            =   120
  62.       TabIndex        =   17
  63.       Top             =   4440
  64.       Width           =   2175
  65.    End
  66.    Begin FSSocket FSSocket1 
  67.       Connect         =   0   'False
  68.       EOL             =   ""
  69.       HostAddress     =   ""
  70.       HostName        =   ""
  71.       InputBufferSize =   4096
  72.       Left            =   1920
  73.       Listen          =   0   'False
  74.       ListenPort      =   0
  75.       OutputBufferSize=   4096
  76.       PortNumber      =   0
  77.       Protocol        =   0  'TCP
  78.       ServiceName     =   ""
  79.       Top             =   960
  80.    End
  81.    Begin CommandButton StopListenButt 
  82.       Caption         =   "Stop Listen"
  83.       Enabled         =   0   'False
  84.       Height          =   375
  85.       Left            =   1080
  86.       TabIndex        =   16
  87.       Top             =   5640
  88.       Width           =   1215
  89.    End
  90.    Begin CheckBox ListenMark 
  91.       BackColor       =   &H00C0C0C0&
  92.       Caption         =   "Listening"
  93.       Height          =   255
  94.       Left            =   120
  95.       TabIndex        =   15
  96.       Top             =   4920
  97.       Width           =   1215
  98.    End
  99.    Begin TextBox LPText 
  100.       Height          =   285
  101.       Left            =   120
  102.       TabIndex        =   3
  103.       Text            =   "Text1"
  104.       Top             =   5640
  105.       Width           =   855
  106.    End
  107.    Begin CommandButton DisconnButt 
  108.       Caption         =   "Disconnect"
  109.       Enabled         =   0   'False
  110.       Height          =   375
  111.       Left            =   1080
  112.       TabIndex        =   5
  113.       Top             =   6360
  114.       Width           =   1215
  115.    End
  116.    Begin TextBox INDATA 
  117.       FontBold        =   -1  'True
  118.       FontItalic      =   0   'False
  119.       FontName        =   "Courier New"
  120.       FontSize        =   8.25
  121.       FontStrikethru  =   0   'False
  122.       FontUnderline   =   0   'False
  123.       Height          =   6375
  124.       Left            =   2400
  125.       MultiLine       =   -1  'True
  126.       ScrollBars      =   3  'Both
  127.       TabIndex        =   10
  128.       TabStop         =   0   'False
  129.       Text            =   "Text1"
  130.       Top             =   0
  131.       Width           =   4575
  132.    End
  133.    Begin TextBox OUTDATA 
  134.       Height          =   285
  135.       Left            =   3120
  136.       TabIndex        =   6
  137.       Text            =   "Text2"
  138.       Top             =   6480
  139.       Width           =   3735
  140.    End
  141.    Begin CommandButton ListenButt 
  142.       Caption         =   "Listen"
  143.       Height          =   375
  144.       Left            =   1080
  145.       TabIndex        =   4
  146.       Top             =   5280
  147.       Width           =   1215
  148.    End
  149.    Begin OptionButton UDP 
  150.       BackColor       =   &H00C0C0C0&
  151.       Caption         =   "UDP"
  152.       Height          =   255
  153.       Left            =   120
  154.       TabIndex        =   9
  155.       Top             =   1320
  156.       Width           =   1095
  157.    End
  158.    Begin OptionButton TCP 
  159.       BackColor       =   &H00C0C0C0&
  160.       Caption         =   "TCP"
  161.       Height          =   255
  162.       Left            =   120
  163.       TabIndex        =   1
  164.       Top             =   960
  165.       Value           =   -1  'True
  166.       Width           =   1095
  167.    End
  168.    Begin TextBox HSTADDR 
  169.       Height          =   285
  170.       Left            =   120
  171.       TabIndex        =   8
  172.       TabStop         =   0   'False
  173.       Text            =   "Text4"
  174.       Top             =   2640
  175.       Width           =   2175
  176.    End
  177.    Begin TextBox PORTNUM 
  178.       Height          =   285
  179.       Left            =   120
  180.       TabIndex        =   2
  181.       TabStop         =   0   'False
  182.       Text            =   "Text5"
  183.       Top             =   3240
  184.       Width           =   2175
  185.    End
  186.    Begin CheckBox CNTD 
  187.       BackColor       =   &H00C0C0C0&
  188.       Caption         =   "Connected"
  189.       Height          =   255
  190.       Left            =   120
  191.       TabIndex        =   7
  192.       TabStop         =   0   'False
  193.       Top             =   480
  194.       Width           =   1455
  195.    End
  196.    Begin CheckBox RDYTOSND 
  197.       BackColor       =   &H00C0C0C0&
  198.       Caption         =   "Ready to Send"
  199.       Height          =   255
  200.       Left            =   120
  201.       TabIndex        =   0
  202.       TabStop         =   0   'False
  203.       Top             =   120
  204.       Width           =   1695
  205.    End
  206.    Begin Label Label5 
  207.       AutoSize        =   -1  'True
  208.       BackStyle       =   0  'Transparent
  209.       Caption         =   "Remote Name"
  210.       Height          =   195
  211.       Left            =   120
  212.       TabIndex        =   23
  213.       Top             =   1800
  214.       Width           =   1200
  215.    End
  216.    Begin Label Label6 
  217.       AutoSize        =   -1  'True
  218.       BackStyle       =   0  'Transparent
  219.       Caption         =   "Local Address"
  220.       Height          =   195
  221.       Left            =   120
  222.       TabIndex        =   20
  223.       Top             =   3600
  224.       Width           =   1215
  225.    End
  226.    Begin Label Label7 
  227.       AutoSize        =   -1  'True
  228.       BackStyle       =   0  'Transparent
  229.       Caption         =   "Local Port"
  230.       Height          =   195
  231.       Left            =   120
  232.       TabIndex        =   19
  233.       Top             =   4200
  234.       Width           =   885
  235.    End
  236.    Begin Label Label2 
  237.       AutoSize        =   -1  'True
  238.       BackStyle       =   0  'Transparent
  239.       Caption         =   "Port"
  240.       Height          =   195
  241.       Left            =   120
  242.       TabIndex        =   13
  243.       Top             =   5400
  244.       Width           =   360
  245.    End
  246.    Begin Label Label1 
  247.       Alignment       =   1  'Right Justify
  248.       AutoSize        =   -1  'True
  249.       BackStyle       =   0  'Transparent
  250.       Caption         =   "Input:"
  251.       Height          =   255
  252.       Left            =   2520
  253.       TabIndex        =   14
  254.       Top             =   6480
  255.       Width           =   510
  256.    End
  257.    Begin Label Label3 
  258.       AutoSize        =   -1  'True
  259.       BackStyle       =   0  'Transparent
  260.       Caption         =   "Remote Address"
  261.       Height          =   195
  262.       Left            =   120
  263.       TabIndex        =   12
  264.       Top             =   2400
  265.       Width           =   1395
  266.    End
  267.    Begin Label Label4 
  268.       AutoSize        =   -1  'True
  269.       BackStyle       =   0  'Transparent
  270.       Caption         =   "Remote Port"
  271.       Height          =   195
  272.       Left            =   120
  273.       TabIndex        =   11
  274.       Top             =   3000
  275.       Width           =   1065
  276.    End
  277.    Begin Line Line2 
  278.       X1              =   2400
  279.       X2              =   0
  280.       Y1              =   840
  281.       Y2              =   840
  282.    End
  283.    Begin Line Line1 
  284.       X1              =   2400
  285.       X2              =   2400
  286.       Y1              =   0
  287.       Y2              =   6960
  288.    End
  289. Sub Connect_Click ()
  290. On Error GoTo errz
  291.     fssocket1.ListenPort = LPText.Text
  292.     fssocket1.Connect = True
  293.     LocalAddress.Text = fssocket1.LocalAddress
  294.     LocalPort.Text = fssocket1.LocalPort
  295.     StopListenButt.Enabled = False
  296.     ListenButt.Enabled = False
  297.     DisconnButt.Enabled = True
  298.     Exit Sub
  299. errz:
  300.     MsgBox fssocket1.WSALastErrorMsg
  301.     Resume Next
  302. End Sub
  303. Sub DisconnButt_Click ()
  304.     fssocket1.Connect = False
  305. End Sub
  306. Sub Form_Load ()
  307.     Show
  308.     fssocket1.EOL = Chr$(10)
  309.     INDATA.Text = ""
  310.     OUTDATA.Text = ""
  311.     hstaddr.Text = fssocket1.HostAddress
  312.     HSTNAME.Text = fssocket1.HostName
  313.     PORTNUM.Text = fssocket1.PortNumber
  314.     LPText.Text = fssocket1.ListenPort
  315.     LocalAddress.Text = fssocket1.LocalAddress
  316.     LocalPort.Text = fssocket1.LocalPort
  317.     If fssocket1.Protocol = 0 Then
  318.         TCP.Value = True
  319.     Else
  320.         UDP.Value = True
  321.     End If
  322. End Sub
  323. Sub FSSocket1_Connected (StatusCode As Integer, Description As String)
  324.     CNTD.Value = 1
  325.     RDYTOSND.Value = 1
  326.     PORTNUM.Text = fssocket1.PortNumber
  327.     hstaddr.Text = fssocket1.HostAddress
  328.     HSTNAME.Text = fssocket1.HostName
  329.     LocalAddress.Text = fssocket1.LocalAddress
  330.     LocalPort.Text = fssocket1.LocalPort
  331.     ListenMark.Value = 0
  332.     DisconnButt.Enabled = True
  333.     StopListenButt.Enabled = False
  334. End Sub
  335. Sub FSSocket1_DataReceived (Text As String, EOL As Integer)
  336. Static fulstrng As String
  337.     fulstrng = fulstrng + Text
  338.     If EOL Then
  339.         INDATA.SelStart = 32000
  340.         INDATA.SelText = fulstrng & Chr$(13) & Chr$(10)
  341.         fulstrng = ""
  342.     End If
  343. End Sub
  344. Sub FSSocket1_Disconnected (StatusCode As Integer, Description As String)
  345.     LocalAddress.Text = fssocket1.LocalAddress
  346.     LocalPort.Text = fssocket1.LocalPort
  347.     CNTD.Value = 0
  348.     RDYTOSND.Value = 0
  349.     PORTNUM.Text = ""
  350.     hstaddr.Text = ""
  351.     HSTNAME.Text = ""
  352.     If fssocket1.Listen = False Then
  353.         ListenMark.Value = 0
  354.         StopListenButt.Enabled = False
  355.     Else
  356.         ListenMark.Value = 1
  357.         StopListenButt.Enabled = True
  358.     End If
  359.     DisconnButt.Enabled = False
  360. End Sub
  361. Sub FSSocket1_ReadyToSend ()
  362.    RDYTOSND.Value = 1
  363. End Sub
  364. Sub ListenButt_Click ()
  365. On Error GoTo errx
  366.     fssocket1.ListenPort = LPText.Text
  367.     fssocket1.Listen = True
  368.     LPText.Text = fssocket1.ListenPort
  369.     text1.Text = fssocket1.ListenPort \ 256
  370.     text2.Text = fssocket1.ListenPort Mod 256
  371.     StopListenButt.Enabled = True
  372.     ListenButt.Enabled = False
  373.     DisconnButt.Enabled = False
  374.     If fssocket1.Listen = False Then
  375.         ListenMark.Value = 0
  376.     Else
  377.         ListenMark.Value = 1
  378.     End If
  379.     Exit Sub
  380. errx:
  381.     MsgBox "Error number " & Err & " occurred at line " & Erl
  382.     MsgBox fssocket1.WSALastErrorMsg
  383.     Resume Next
  384. End Sub
  385. Sub OUTDATA_KeyPress (keyascii As Integer)
  386. On Error GoTo cantsend
  387. Dim x As Integer
  388.     If keyascii = 13 Then
  389.         If fssocket1.Connect = True Then
  390.             If fssocket1.Protocol = 1 Then
  391.                 fssocket1.HostAddress = hstaddr.Text
  392.             End If
  393.             fssocket1.Send = OUTDATA.Text & Chr$(10)
  394.         End If
  395.         OUTDATA.Text = ""
  396.         keyascii = 0
  397.     End If
  398. Exit Sub
  399. cantsend:
  400.     If fssocket1.WSALastError = 10035 Then
  401.         RDYTOSND.Value = 0
  402.         While RDYTOSND.Value = 0
  403.             DoEvents
  404.         Wend
  405.     Else
  406.         MsgBox fssocket1.WSALastErrorMsg
  407.         Exit Sub
  408.     End If
  409.     Resume
  410. End Sub
  411. Sub StopListenButt_Click ()
  412.     fssocket1.Listen = False
  413.     If fssocket1.Listen = False Then
  414.         ListenMark.Value = 0
  415.     Else
  416.         ListenMark.Value = 1
  417.     End If
  418.     ListenButt.Enabled = True
  419.     StopListenButt.Enabled = False
  420.     DisconnButt.Enabled = False
  421. End Sub
  422. Sub TCP_Click ()
  423.     fssocket1.Protocol = 0
  424.     ListenButt.Enabled = True
  425.     StopListenButt.Enabled = False
  426.     Connect.Enabled = False
  427. End Sub
  428. Sub UDP_Click ()
  429.     fssocket1.Protocol = 1
  430.     'ListenButt.Enabled = False
  431.     'StopListenButt.Enabled = False
  432.     Connect.Enabled = True
  433. End Sub
  434.